﻿using Caliburn.Micro;
using SD.Infrastructure.DTOBase;
using SD.Infrastructure.WPF.Caliburn.Aspects;
using SD.Infrastructure.WPF.Caliburn.Base;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.ServiceModel.Extensions;
using System.Text;
using System.Threading.Tasks;
using SlamDunk.MES.IAppService.DTOs.Outputs.PlanContext;
using SlamDunk.MES.IAppService.Interfaces;
using SlamDunk.MES.Presentation.Models;
using SlamDunk.MES.Presentation.Models.NotifyModels;


namespace SlamDunk.MES.Client.ViewModels.Report
{
    /// <summary>
    /// 查看作业计划统计明细ViewModel
    /// </summary>
    public class ExecutionPlanReportDetailtViewModel : ScreenBase
    {
        #region # 字段及构造器
        /// <summary>
        /// 计划管理服务契约接口代理
        /// </summary>
        private readonly ServiceProxy<IPlanContract> _planContract;

        /// <summary>
        /// 窗口管理器
        /// </summary>
        private readonly IWindowManager _windowManager;

        /// <summary>
        /// 依赖注入构造器
        /// </summary>
        public ExecutionPlanReportDetailtViewModel(ServiceProxy<IPlanContract> planContract, IWindowManager windowManager)
        {
            this._planContract = planContract;
            this._windowManager = windowManager;
        }
        #endregion

        #region # 属性
        #region 作业计划列表 —— ObservableCollection<Wrap<ProductionPlanInfo>> ProductionPlans
        /// <summary>
        /// 作业计划列表
        /// </summary>
        [DependencyProperty]
        public ObservableCollection<ExecutionPlanInfo> ExecutionPlans { get; set; }
        #endregion
        #endregion

        #region # 方法
        //Initializations
        #region 加载 —— async Task Load(ProductionPlanReportInfo _productionPlanReportInfo)
        /// <summary>
        /// 加载
        /// </summary>
        public async Task Load(ProductionPlanSummaryNm productionPlanSummaryNm)
        {
            //查询生成计划
            PageModel<ExecutionPlanInfo> pageModel = await Task.Run(() => this._planContract.Channel.GetExecutionPlansByPage(
                null,//关键字
                null, //产品Id
                null, //工艺Id
                null, //物料清单Id
                null,//生产计划Id
                productionPlanSummaryNm.ExecutionPlanStatus,//作业计划状态
                null, //审核状态
                null, //是否已生成工单
                null, //是否已质检
                productionPlanSummaryNm.PlanStartTime,//开始时间
                productionPlanSummaryNm.PlanEndTime, //结束时间
                productionPlanSummaryNm.FacilityId,//工厂模型Id
                1, //页码
                int.MaxValue));
            ExecutionPlans = new ObservableCollection<ExecutionPlanInfo>(pageModel.Datas);
        }
        #endregion
        #endregion

    }
}
